package com.cin.cma.common.enums;

import cn.hutool.core.util.StrUtil;
import lombok.Getter;


@Getter
public enum ScheduleStatusEnum {
    SELL_STOP("SELL_STOP", "已停售"),
    SELL_OPEN("SELL_OPEN", "已启用"),
    INVALID("INVALID", "已失效"),
    ;

    private final String code;
    private final String desc;

    ScheduleStatusEnum(String code, String desc) {
        this.code = code;
        this.desc = desc;
    }

    /**
     * 根据状态码获取枚举
     *
     * @param status
     * @return
     */
    public static ScheduleStatusEnum buildScheduleStatusEnum(String status) {
        if (StrUtil.isBlank(status)) {
            return INVALID;
        }

        switch (status) {
            case "N":
                return SELL_STOP;
            case "Y":
                return SELL_OPEN;
            case "INVALID":
                return INVALID;
            default:
                return INVALID;
        }
    }
}
